########################### apm-server #######################################

apm-server:
  host: "localhost:8200"
  secret_token: {{ secret_token }}

  {% if max_event_size %}
  # Maximum allowed size in bytes of a single event
  max_event_size: {{ max_event_size }}
  {% endif %}

  {% if ssl_enabled %}
  ssl.enabled: {{ ssl_enabled }}
  {% endif %}

  {% if ssl_certificate_authorities %}
  ssl.certificate_authorities: {{ ssl_certificate_authorities }}
  {% endif %}

  {% if ssl_certificate %}
  ssl.certificate:  {{ ssl_certificate }}
  {% endif %}

  {% if ssl_key %}
  ssl.key: {{ ssl_key }}
  {% endif %}

  {% if ssl_key_passphrase %}
  ssl.key_passphrase: {{ ssl_key_passphrase }}
  {% endif %}

  {% if ssl_supported_protocols %}
  ssl.supported_protocols: {{ ssl_supported_protocols }}
  {% endif %}

  {% if ssl_client_authentication %}
  ssl.client_authentication: {{ ssl_client_authentication }}
  {% endif %}

  {% if ssl_cipher_suites %}
  ssl.cipher_suites: {{ ssl_cipher_suites }}
  {% endif %}

  rum.enabled: {{ enable_rum }}
  rum.rate_limit: 3
  rum.allow_origins: {{ allow_origins }}
  rum.library_pattern: "~/test|library"
  rum.exclude_from_grouping: "~/test"
  rum.event_rate.limit: 16

  {% if rum_sourcemapping_disabled %}
  rum.source_mapping.enabled: false
  {% endif %}

  {% if smap_cache_expiration %}
  rum.source_mapping.cache.expiration: {{ smap_cache_expiration}}
  {% endif %}
  {% if smap_index_pattern %}
  rum.source_mapping.index_pattern: {{ smap_index_pattern}}
  {% endif %}

  {% if expvar_enabled %}
  expvar.enabled: {{ expvar_enabled }}
  {% endif %}
  {% if expvar_url %}
  expvar.url: {{ expvar_url }}
  {% endif %}

  {% if register_pipeline_enabled %}
  register.ingest.pipeline.enabled: {{ register_pipeline_enabled }}
  {% endif %}
  {% if register_pipeline_overwrite %}
  register.ingest.pipeline.overwrite: {{ register_pipeline_overwrite }}
  {% endif %}

  {% if instrumentation_enabled %}
  instrumentation.enabled: {{ instrumentation_enabled }}
  {% endif %}
  {% if profiling_cpu_enabled %}
  instrumentation.profiling.cpu.enabled: {{ profiling_cpu_enabled }}
  {% endif %}
  {% if profiling_cpu_interval %}
  instrumentation.profiling.cpu.interval: {{ profiling_cpu_interval }}
  {% endif %}
  {% if profiling_cpu_duration %}
  instrumentation.profiling.cpu.duration: {{ profiling_cpu_duration }}
  {% endif %}
  {% if profiling_heap_enabled %}
  instrumentation.profiling.heap.enabled: {{ profiling_heap_enabled }}
  {% endif %}
  {% if profiling_heap_interval %}
  instrumentation.profiling.heap.interval: {{ profiling_heap_interval }}
  {% endif %}

  {% if mode %}
  mode: {{ mode }}
  {% endif %}

  {% if ilm_enabled %}
  ilm.enabled: {{ ilm_enabled }}
  {% endif %}

  {% if ilm_policies %}
  ilm.setup.mapping:
    - event_type: "error"
      policy_name: "rollover-10-days"
    - event_type: "span"
      policy_name: "apm-rollover-30-days"

  ilm.setup.policies:
    - name: "rollover-10-days"
      policy:
        phases:
          hot:
            actions:
              rollover:
                max_size: "50gb"
                max_age: "10d"
              set_priority:
                priority: 100
    - name: "apm-rollover-30-days"
      policy:
        phases:
          hot:
            actions:
              rollover:
                max_size: "50gb"
                max_age: "30d"
              set_priority:
                priority: 100
          delete:
            actions:
              delete: {}
  {% endif %}

  {% if kibana_enabled is not none or kibana_host is not none %}
  kibana:
    {% if kibana_enabled is not none %}enabled: {{ kibana_enabled }}{% endif %}
    {% if kibana_host is not none %}host: {{ kibana_host }}{% endif %}
  {% endif %}
{% if acm_cache_expiration is not none %}  agent.config.cache.expiration: {{ acm_cache_expiration }}{% endif %}


############################# Setup ##########################################

{% if override_template %}

setup.template.name: {{ override_template }}
setup.template.pattern: {{ override_template }}*
setup.template.settings:
  index.number_of_shards: 1
  index.number_of_replicas: 0
  index.refresh_interval: 1ms

{% endif %}

############################# Output ##########################################

# File as output
output.file:
  enabled: {{ file_enabled|default("true") }}
  # Path to the directory where to save the generated files. The option is mandatory.
  path: {{ output_file_path|default(beat.working_dir + "/output") }}

  # Name of the generated files. The default is `apm-server` and it generates
  # files: `apm-server`, `apm-server.1`, `apm-server.2`, etc.
  #filename: "{{ output_file_filename|default("apm-server") }}"

  # Maximum size in kilobytes of each file. When this size is reached, the files are
  # rotated. The default value is 10 MB.
  #rotate_every_kb: {{ rotate_every_kb | default(1000) }}
  # Maximum number of files under path. When this number of files is reached, the
  # oldest file is deleted and the rest are shifted from last to first. The default
  # is 7 files.
  #number_of_files: 7

{% if elasticsearch_host %}
output.elasticsearch:
  hosts: ["{{ elasticsearch_host }}"]

  {% if override_index %}
  index: {{ override_index }}
  {% endif %}

  {% if disable_pipeline %}
  pipeline: _none
  {% endif %}

  {% if disable_pipelines %}
  pipelines:
  - pipeline: _none
  {% endif %}

{% endif %}

############################# Beat #########################################

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
# If this options is not defined, the hostname is used.
#name:

# The tags of the shipper are included in their own field with each
# transaction published. Tags make it easy to group servers by different
# logical properties.
#tags: ["service-X", "web-tier"]


############################# Logging #########################################

{% if logging_json or logging_level %}
logging:
{% else %}
#logging:
{% endif %}
  # Send all logging output to syslog. On Windows default is false, otherwise
  # default is true.
  #to_syslog: true

  # Write all logging output to files. Beats automatically rotate files if configurable
  # limit is reached.
  #to_files: false

  # Enable debug output for selected components.
  #selectors: []

{% if logging_json %}
  # Set to true to log messages in json format.
  json: {{ logging_json }}
{% endif %}

{% if logging_level %}
  # Set log level
  level: {{ logging_level }}
{% endif %}

  #files:
    # The directory where the log files will written to.
    #path: /var/log/apm-server

    # The name of the files where the logs are written to.
    #name: apm-server

    # Configure log file size limit. If limit is reached, log file will be
    # automatically rotated
    #rotateeverybytes: 10485760 # = 10MB

    # Number of rotated log files to keep. Oldest files will be deleted first.
    #keepfiles: 7

queue.mem.flush.min_events: {{ queue_flush }}
